package com.software.backend.indexshow.controller;


import com.software.backend.indexshow.entity.Post;
import com.software.backend.indexshow.service.PostInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author Charon
 * @version 1.0
 * @date 2022/12/24 15:03
 */


@RestController
@RequestMapping("/post")
public class PostInfoController {

    @Autowired
    private PostInfoService postInfoService;

    @GetMapping("/findPostInfo")
    public List<Post> findPostInfo(@RequestParam(value = "page", defaultValue = "0") Integer page,
                                   @RequestParam(value = "size", defaultValue = "5") Integer size) {
        Page<Post> postInfo = postInfoService.findPostInfo(page, size);
        List<Post> content = postInfo.getContent();
        return content;
    }
}
